package leecode

type MyStack struct {
	queue []int
}

func Constructor235() MyStack {
	return MyStack{make([]int, 0)}
}

func (this *MyStack) Push(x int) {
	this.queue = append(this.queue, x)
}

func (this *MyStack) Pop() int {
	//拿到切片最后面的一个元素
	var result int
	if len(this.queue) == 0 {
		return -1
	}
	result = this.queue[len(this.queue)-1]
	this.queue = this.queue[:len(this.queue)-1]
	return result
}

func (this *MyStack) Top() int {
	result := this.Pop()
	this.queue = append(this.queue, result)
	return result
}

func (this *MyStack) Empty() bool {
	return len(this.queue) == 0
}
